package com.ruoyi.appreciate.stucomposition.service.impl;

import java.util.List;

import com.ruoyi.appreciate.stucomposition.domain.StudentComposition;
import com.ruoyi.appreciate.stucomposition.mapper.StudentCompositionMapper;
import com.ruoyi.appreciate.stucomposition.service.IStudentCompositionService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 学生作品Service业务层处理
 * 
 * @author duanxinli
 * @date 2025-09-15
 */
@Service
public class StudentCompositionServiceImpl implements IStudentCompositionService
{
    @Autowired
    private StudentCompositionMapper studentCompositionMapper;

    /**
     * 查询学生作品
     * 
     * @param id 学生作品主键
     * @return 学生作品
     */
    @Override
    public StudentComposition selectStudentCompositionById(String id)
    {
        return studentCompositionMapper.selectStudentCompositionById(id);
    }

    /**
     * 查询学生作品列表
     * 
     * @param studentComposition 学生作品
     * @return 学生作品
     */
    @Override
    public List<StudentComposition> selectStudentCompositionList(StudentComposition studentComposition)
    {
        return studentCompositionMapper.selectStudentCompositionList(studentComposition);
    }

    /**
     * 新增学生作品
     * 
     * @param studentComposition 学生作品
     * @return 结果
     */
    @Override
    public int insertStudentComposition(StudentComposition studentComposition)

    {
        studentComposition.setId(IdUtils.fastUUID());
        studentComposition.setCreateDate(DateUtils.getNowDate());
        String username = SecurityUtils.getUsername();
        studentComposition.setCreateBy(username);
        studentComposition.setSort(0L);
        studentComposition.setDelFlag(0L);
        return studentCompositionMapper.insertStudentComposition(studentComposition);
    }

    /**
     * 修改学生作品
     * 
     * @param studentComposition 学生作品
     * @return 结果
     */
    @Override
    public int updateStudentComposition(StudentComposition studentComposition)
    {
        return studentCompositionMapper.updateStudentComposition(studentComposition);
    }

    /**
     * 批量删除学生作品
     * 
     * @param ids 需要删除的学生作品主键
     * @return 结果
     */
    @Override
    public int deleteStudentCompositionByIds(String[] ids)
    {
        return studentCompositionMapper.deleteStudentCompositionByIds(ids);
    }

    /**
     * 删除学生作品信息
     * 
     * @param id 学生作品主键
     * @return 结果
     */
    @Override
    public int deleteStudentCompositionById(String id)
    {
        return studentCompositionMapper.deleteStudentCompositionById(id);
    }
}
